import Vue from 'vue'
import Vuex from 'vuex'
import API from '@/common/api/api'
Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
    choiceState: 'home',
    loginState: 'maintainor',
    token: '',
    user: {},
    category: '',
    phone: '',
    equipmentList: [],
    newsList: [],
    alarmNum: 1
  },
  mutations: {
    changeChoiceState (state, val) {
      state.choiceState = val
    },
    setState (state, val) {
      state.loginState = val
    },
    setToken (state, val) {
      state.token = val
    },
    setUser (state, val) {
      state.user = val
    },
    setCategory (state, val) {
      state.category = val
    },
    setPhone (state, val) {
      state.phone = val
    },
    setEquipment (state, val) {
      state.equipmentList.push(val)
    },
    setNews (state, val) {
      state.newsList.push(val)
    },
    setAlarmNum (state, val) {
      state.alarmNum = val
    }
  },
  actions: {
    async getVerificationCode ({ commit }, params) {
      return API.getVerificationCode(params)
    },
    async login ({ commit }, params) {
      return API.login(params)
    },
    async getWeiXinParam ({ commit }, params) {
      return API.getWeiXinParam(params)
    },
    async quitLanding ({ commit }, params) {
      return API.quitLanding(params)
    },
    async intercalateList ({ commit }, params) {
      return API.intercalateList(params)
    },
    async getdevicedetail ({ commit }, params) {
      return API.getdevicedetail(params)
    },
    async accetcategory ({ commit }, params) {
      return API.accetcategory(params)
    },
    async addevice ({ commit }, params) {
      return API.addevice(params)
    },
    async assign ({ commit }, params) {
      return API.assign(params)
    },
    async mybuildinglist ({ commit }, params) {
      return API.mybuildinglist(params)
    },
    async mybuildingdetails ({ commit }, params) {
      return API.mybuildingdetails(params)
    },
    async assetevent ({ commit }, params) {
      return API.assetevent(params)
    },
    async assetsList ({ commit }, params) {
      return API.assetsList(params)
    },
    async removeWarning ({ commit }, params) {
      return API.removeWarning(params)
    },
    async upload ({ commit }, params, config) {
      return API.upload(params, config)
    },
    async mysuperiors ({ commit }, params) {
      return API.mysuperiors(params)
    },
    async myproprietors ({ commit }, params) {
      return API.myproprietors(params)
    },
    async mymaitainors ({ commit }, params) {
      return API.mymaitainors(params)
    },
    async sitelist ({ commit }, params) {
      return API.sitelist(params)
    },
    async mydresouces ({ commit }, params) {
      return API.mydresouces(params)
    },
    async mysuperiordetails ({ commit }, params) {
      return API.mysuperiordetails(params)
    },
    async proprietordetails ({ commit }, params) {
      return API.proprietordetails(params)
    },
    async maitainordetails ({ commit }, params) {
      return API.maitainordetails(params)
    },
    async sitedetail ({ commit }, params) {
      return API.sitedetail(params)
    },
    async dresoucetails ({ commit }, params) {
      return API.dresoucetails(params)
    },
    async assetdetails ({ commit }, params) {
      return API.assetdetails(params)
    },
    async sitefix ({ commit }, params) {
      return API.sitefix(params)
    }
  }
})
export default store
